<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>更新交易记录表</title>
</head>
<body>
<form>
    <table border="1">
        <tr><td colspan="2"><h1>更新交易记录表内容</h1></td></tr>
        <tr>
            <td>记录ID</td>
            <td>
                    <span id="recordId_txt"></span><input type="hidden" id="recordId" name="recordId"/>
            </td>
        </tr>
        <tr>
            <td>订单编号 yyyymmddnnnnnnnn</td>
            <td>
                    <input type="text" id="orderSn" name="orderSn"/>
            </td>
        </tr>
        <tr>
            <td>下单人ID</td>
            <td>
                    <input type="text" id="customerId" name="customerId"/>
            </td>
        </tr>
        <tr>
            <td>回购方式:1上门回收,2邮寄</td>
            <td>
                    <input type="text" id="recycleMethod" name="recycleMethod"/>
            </td>
        </tr>
        <tr>
            <td>订单金额</td>
            <td>
                    <input type="text" id="orderMoney" name="orderMoney"/>
            </td>
        </tr>
        <tr>
            <td>交易时间</td>
            <td>
                    <input type="text" id="tradingDate" name="tradingDate"/>
            </td>
        </tr>
        <tr>
            <td>到账时间</td>
            <td>
                    <input type="text" id="payTime" name="payTime"/>
            </td>
        </tr>
        <tr>
            <td>订单状态</td>
            <td>
                    <input type="text" id="orderStatus" name="orderStatus"/>
            </td>
        </tr>
        <tr>
            <td>最后修改时间</td>
            <td>
                    <input type="text" id="modifiedTime" name="modifiedTime"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other1" name="other1"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other2" name="other2"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" id="tijiao" value="提交"/>
                <input type="reset" value="重置"/>
            </td>
        </tr>
    </table>
</form>
<script src="/js/jquery-1.12.4.js"></script>
    <script>
    var param = location.href.substring(location.href.indexOf('?')+1);
    $.getJSON("/tradingrecord/findById.json",param,function(detail){
        $("#recordId_txt").text(detail.recordId);
        $("#recordId").val(detail.recordId);
        $("#orderSn").val(detail.orderSn);
        $("#customerId").val(detail.customerId);
        $("#recycleMethod").val(detail.recycleMethod);
        $("#orderMoney").val(detail.orderMoney);
        $("#tradingDate").val(detail.tradingDate);
        $("#payTime").val(detail.payTime);
        $("#orderStatus").val(detail.orderStatus);
        $("#modifiedTime").val(detail.modifiedTime);
        $("#other1").val(detail.other1);
        $("#other2").val(detail.other2);
    });
    //点击提交按钮
    $("#tijiao").click(function(){
        if(!$("#orderSn").val()){
            alert("订单编号 yyyymmddnnnnnnnn不能为空");
            return;
        }
        if(!$("#customerId").val()){
            alert("下单人ID不能为空");
            return;
        }
        if(!$("#recycleMethod").val()){
            alert("回购方式:1上门回收,2邮寄不能为空");
            return;
        }
        if(!$("#orderMoney").val()){
            alert("订单金额不能为空");
            return;
        }
        if(!$("#tradingDate").val()){
            alert("交易时间不能为空");
            return;
        }
        if(!$("#payTime").val()){
            alert("到账时间不能为空");
            return;
        }
        if(!$("#orderStatus").val()){
            alert("订单状态不能为空");
            return;
        }
        if(!$("#modifiedTime").val()){
            alert("最后修改时间不能为空");
            return;
        }
        if(!$("#other1").val()){
            alert("其他不能为空");
            return;
        }
        if(!$("#other2").val()){
            alert("其他不能为空");
            return;
        }
        
        $.post("/tradingrecord/update.json",$("form").serialize(),function(result){
            if(result.flag==true){
                alert(result.msg);
                location.href="/admin/tradingrecord/list.html";
            }else{
                alert(result.msg);
            }
        })

    })
</script>

</body>
</html>